
/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2015原作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.scripting;

import java.util.Map;

import org.springframework.lang.Nullable;

/**
 * Spring's strategy interface for evaluating a script.
 *
 * <p>Aside from language-specific implementations, Spring also ships
 * a version based on the standard {@code javax.script} package (JSR-223):
 * {@link org.springframework.scripting.support.StandardScriptEvaluator}.
 *
 * @author Juergen Hoeller
 * @author Costin Leau
 * @since 4.0
 */
/**
 *Spring用于评估脚本的策略接口。
 *
 *＜p＞除了特定于语言的实现之外，Spring还提供
 *基于标准{@codejavax.script}包（JSR-223）的版本：
 *｛@link org.springframework.scripting.support.StandardScriptEvaluator｝。
 *
 *@作者于尔根·霍勒
 *@作者Costin Leau
 *@自4.0起
 */
public interface ScriptEvaluator {

	/**
	 * Evaluate the given script.
	 * @param script the ScriptSource for the script to evaluate
	 * @return the return value of the script, if any
	 * @throws ScriptCompilationException if the evaluator failed to read,
	 * compile or evaluate the script
	 */
	/**
	 *评估给定的脚本。
	 *@param script要评估的脚本的ScriptSource
	 *@返回脚本的返回值（如果有的话）
	 *如果计算器读取失败，@throws ScriptCompilationException，
	 *编译或评估脚本
	 */
	@Nullable
	Object evaluate(ScriptSource script) throws ScriptCompilationException;

	/**
	 * Evaluate the given script with the given arguments.
	 * @param script the ScriptSource for the script to evaluate
	 * @param arguments the key-value pairs to expose to the script,
	 * typically as script variables (may be {@code null} or empty)
	 * @return the return value of the script, if any
	 * @throws ScriptCompilationException if the evaluator failed to read,
	 * compile or evaluate the script
	 */
	/**
	 *使用给定的参数评估给定的脚本。
	 *@param script要评估的脚本的ScriptSource
	 *@param自变量要向脚本公开的键值对，
	 *通常作为脚本变量（可以是{@code-null}或空）
	 *@返回脚本的返回值（如果有的话）
	 *如果计算器读取失败，@throws ScriptCompilationException，
	 *编译或评估脚本
	 */
	@Nullable
	Object evaluate(ScriptSource script, @Nullable Map<String, Object> arguments) throws ScriptCompilationException;

}
